package tech.aistar.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tech.aistar.pojo.User;

import java.util.List;

//mapper层 --对应传统的dao层(data access object)
//
public interface UserMapper {
    //查找t_user表中所有数据
    //mybatis一行一行到t_user表取数据
    //获取每一行数据之后，将数据存到单个User对象中
    //将每个User对象放入List集合
    @Select("select * from tb_user where username=#{username} and password = #{password}")
    User select(@Param("username") String username, @Param("password")String password);

    @Select("select * from tb_user where username=#{username}")
    User selectByUsername(String usernmae);

    @Insert("insert into tb_user values(null,#{username},#{password})")
    void add(User user);



    @Select("select * from t_user where email=#{value}")
    User findByEmail(String email);


}
